package com.example.demo_android;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class DEMO_ANDROID extends Activity {

	

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
				
		setContentView(R.layout.activity_demo__android);
		cls_sinhvien new_sv = new cls_sinhvien();  
		new_sv=new_sv.GET_TENTRUONG();
		AutoCompleteTextView singtruong;
		singtruong=(AutoCompleteTextView) findViewById(R.id.txt_truong);
		singtruong.setAdapter(new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,new_sv.arr));
        Button button = (Button) findViewById(R.id.btntim);

        button.setOnClickListener(new OnClickListener(){
        	
            //On click function
            public void onClick(View view) {
            	
            	cls_sinhvien new_sv = new cls_sinhvien();           	
            	TextView te4 = (TextView)findViewById(R.id.txt_matruong);
            	TextView te1 = (TextView)findViewById(R.id.txt_sbd);
		        TextView te2 = (TextView)findViewById(R.id.txt_hoten);
		        TextView te5 = (TextView)findViewById(R.id.txt_nsinh);
		        TextView te3 = (TextView)findViewById(R.id.txt_diem);
		        AutoCompleteTextView truong=(AutoCompleteTextView) findViewById(R.id.txt_truong);
		        new_sv.TEN_TRUONG=truong.getText().toString().trim();
				EditText text = (EditText)findViewById(R.id.txtsobdanh);
				new_sv.MA_SO = text.getText().toString().trim();
				new_sv = new_sv.GET_SINHVIEN_SBD();
				  if(new_sv!=null)
				  {
					  if(new_sv.flag==0)
					  {
						  te1.setText(" ");
					      te2.setText(" ");
					      te3.setText(" ");
					      te4.setText("Không tồn tại thông tin tìm kiếm");
					      te5.setText(" ");
					  }
					  else
					  {
						te1.setText("SBD: "+new_sv.SO_BD);
				        te2.setText("Họ tên: "+new_sv.TEN_SV);
				        te3.setText("Tổng điểm: "+new_sv.DIEM_THI);
				        te4.setText("Mã trường: "+new_sv.MA_TRUONG );
				        te5.setText("Ngày sinh: "+new_sv.NGAY_SINH);
					  }
						 
				  }
				  
            }
            });

        }
        
	}

	


